package com.huawei.appmarket.service.store.awk.card;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.GradientDrawable.Orientation;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.horizontalcard.api.card.BaseHorizontalItemCard;
import com.huawei.appmarket.service.store.awk.bean.SubstanceListCardBean;
import o.azb;
import o.cgz;
import o.chc;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.epv;
import o.eqx;
import o.eqz;
import o.erq;
import o.evf;
import o.ewm.c;
import o.ewm.d;
import o.ewm.e;
import o.ewm.h;
import o.ewm.j;
import o.fmw;

public class HorizontalMaterialListItemCard extends BaseHorizontalItemCard implements eqz {
    private TextView ʻ;
    private TextView ʼ;
    private TextView ʽ;
    private String ˊॱ;
    private TextView ˋ;
    private ImageView ॱॱ;
    private View ᐝ;

    public HorizontalMaterialListItemCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        this.ˋ = (TextView) view.findViewById(j.ˉʽ);
        this.ॱॱ = (ImageView) view.findViewById(j.ˊʹ);
        this.ʼ = (TextView) view.findViewById(j.ˊי);
        this.ʻ = (TextView) view.findViewById(j.ˊٴ);
        this.ᐝ = view.findViewById(j.ˉʻ);
        this.ʽ = (TextView) view.findViewById(j.ㆍʼ);
        int ˎ = epv.ˎ(this.ʼॱ, ʼ(), chc.ˋ());
        int ʼ = (int) (((float) ˎ) * epv.ʼ());
        view.setLayoutParams(new LayoutParams(ˎ, ʼ));
        RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.ᐝ.getLayoutParams();
        layoutParams.height = ʼ / 3;
        this.ᐝ.setLayoutParams(layoutParams);
        ʽ(view);
        return this;
    }

    public int ʼ() {
        return chc.ᐝ();
    }

    public void ˏ(CardBean cardBean) {
        super.ˏ(cardBean);
        if (cardBean instanceof SubstanceListCardBean) {
            SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) cardBean;
            String str = (String) this.ॱॱ.getTag();
            if (dof.ˋ(str) || !str.equals(substanceListCardBean.ʻᐝ())) {
                this.ˊॱ = substanceListCardBean.ʿॱ();
                if (evf.ˊ(this.ॱॱ)) {
                    this.ॱॱ.setImageDrawable((Drawable) fmw.ˏ(this.ॱॱ.getContext(), e.ꜞ, "drawable"));
                } else {
                    this.ॱॱ.setImageResource(e.ꜞ);
                }
                this.ᐝ.setBackgroundResource(c.ˉ);
                Context ˋ = ContentManager.getInstant().getContext();
                eqx.ˏ(ˋ.getResources().getDimensionPixelSize(d.ॱʽ), ˋ.getResources().getDimensionPixelSize(d.ॱʼ), this.ॱॱ, substanceListCardBean.ʻᐝ(), "image_default_icon", this, true);
                this.ॱॱ.setTag(substanceListCardBean.ʻᐝ());
                if (TextUtils.isEmpty(substanceListCardBean.ʽˋ())) {
                    this.ˋ.setVisibility(8);
                } else {
                    this.ˋ.setVisibility(0);
                    this.ˋ.setText(substanceListCardBean.ʽˋ());
                }
                this.ʼ.setText(substanceListCardBean.ʾॱ());
                this.ʻ.setText(substanceListCardBean.ʽˊ());
                ˋ(this.ʽ, substanceListCardBean.ˋʻ());
                ᐝ(this.ʻ);
            }
        }
    }

    public void ॱ(Bitmap bitmap) {
        if (bitmap != null) {
            try {
                int ˊʻ;
                int ॱ;
                if (this.ˊᐝ instanceof SubstanceListCardBean) {
                    SubstanceListCardBean substanceListCardBean = (SubstanceListCardBean) this.ˊᐝ;
                    if (substanceListCardBean.ˊʻ() != 0) {
                        ˊʻ = substanceListCardBean.ˊʻ();
                    } else {
                        ॱ = erq.ॱ(this.ˊॱ, bitmap);
                        substanceListCardBean.ʽ(ॱ);
                        ˊʻ = ॱ;
                    }
                } else {
                    ˊʻ = erq.ॱ(this.ˊॱ, bitmap);
                }
                this.ᐝ.setBackground(new GradientDrawable(Orientation.BOTTOM_TOP, new int[]{ˊʻ, 0}));
                boolean ˏ = erq.ˏ(ˊʻ);
                ॱ = -16777216;
                float ˋ = azb.ˋ(this.ʼॱ, d.ߴ);
                if (ˏ) {
                    ॱ = -1;
                    ˋ = azb.ˋ(this.ʼॱ, d.ՙ);
                }
                this.ʼ.setTextColor(ॱ);
                this.ʻ.setTextColor(ॱ);
                this.ʻ.setAlpha(ˋ);
            } catch (IllegalStateException e) {
                Logger.e("SubstanceListCardImmersiveItem", e.toString());
            }
        }
    }

    public int ˊ() {
        return h.ॱՙ;
    }

    public int ˎ() {
        return h.ॱՙ;
    }
}
